package com.example.books;

import java.io.InputStream;



import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class KnowledgeDetailActivity extends Activity {
	private int bookname;
	private String title = "Knowledge";
	TextView tv_title,tv_text;
	ImageView iv_back;
	SeekBar sb;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		setContentView(R.layout.activity_knowledge_detail);
		Bundle bundle = this.getIntent().getExtras();
		bookname = bundle.getInt("name");
		title = bundle.getString("title");
		tv_title=(TextView) findViewById(R.id.knoww_detail_tv_title);
		tv_title.setText(title);
		tv_text=(TextView) findViewById(R.id.txt_textView);
		try {
			InputStream is = getResources().openRawResource(bookname);
			String text = TxtReader.getText(is);
			tv_text.setText(text);
			is.close();
		} catch (Exception e) {
			e.printStackTrace();

		}
		iv_back=(ImageView) findViewById(R.id.back1);
		iv_back.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				intent.setClass(KnowledgeDetailActivity.this,
						BookListActivity.class);
				startActivity(intent);
				overridePendingTransition(R.anim.main_back, R.anim.add_back);
				KnowledgeDetailActivity.this.finish();
			}
		});
		sb=(SeekBar) findViewById(R.id.txt_seekBar);
		sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
				// TODO Auto-generated method stub
			}

			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
				// TODO Auto-generated method stub
			}

			@Override
			public void onProgressChanged(SeekBar seekBar, int progress,
					boolean fromUser) {
				// TODO Auto-generated method stub
				tv_text.setTextSize(progress + 10);

			}
		});
		
	}
	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.knowledge_detail, menu);
		return true;
	}

}
